package com.jiahua.admin.biz.action.customer;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import com.jiahua.user.biz.model.Customer;
import com.jiahua.user.biz.service.CustomerService;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class MemberDeleteAction extends ActionSupport {

	private static final long serialVersionUID = -1588256984228637681L;

	Logger log = Logger.getLogger(MemberDeleteAction.class.getClass());

	CustomerService customerService;

	private List<Customer> customerList;

	public List<Customer> getCustomerList() {
		return customerList;
	}

	public void setCustomerList(List<Customer> customerList) {
		this.customerList = customerList;
	}

	public void setCustomerService(CustomerService customerService) {
		this.customerService = customerService;
	}

	@Override
	public String execute() throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest();
		String id = request.getParameter("deleteId");
		log.debug("delete member : " + id);
		delMember(id);
		customerList = getMemberList();
		return Action.SUCCESS;
	}

	private List<Customer> getMemberList() {
		List<Customer> list = customerService.listCustomer(100);
		return list;
	}

	private boolean delMember(String id) {
		return customerService.deleteCustomer(id);
	}
}
